<?php
require_once 'AbstractEmail.class.php';

class Email extends AbstractEmail {
	
	private $to;
	private $from;
	private $name;
	private $subject;
	private $message;
	
	private $priority = PRIORITY_MEDIUM;
	
	public function getTo(){
		return $this->to;
	}
	
	public function setTo($to){
		$this->to = $to;
	}
	
	public function getFrom(){
		return $this->from;
	}
	
	public function setFrom($from){
		$this->from = $from;
	}
	
	public function getName(){
		return $this->name;
	}
	
	public function setName($name){
		$this->name = $name;
	}

	public function getSubject(){
		return $this->subject;
	}
	
	public function setSubject($subject){
		$this->subject = $subject;
	}
	
	public function getMessage(){
		return $this->message;
	}
	
	public function setMessage($message){
		$this->message = $message;
	}
	
	/**
	 * Default constructor
	 */
	public function __construct() {
	}
	
	/**
	 * Send the email.
	 * @see classes/core/util/email/IEmail::send()
	 */
	public function send(){
		return mail($this->getTo(),$this->getSubject(),$this->getMessage(),$this->getHeader());
	}
	
	/**
	 * Get the MIME header.
	 */
	private function getHeader(){
		$headers  = "MIME-Version: 1.0\n";
		$headers .= "Content-Type: text/html; charset='utf-8'\n";
		$headers .= "From: " . $this->getName() . " <" . $this->getFrom() . ">\n";
		$headers .= "Return-Path: <" . $this->getFrom() . ">\n";
		$headers .= "Reply-to: " . $this->getName() . " <" . $this->getFrom() . ">\n";
		$headers .= "X-Priority: " . $this->priority . "\n";
		
		return $headers;
	}
	
	public function usePriorityHigh(){
		$this->priority = PRIORITY_HIGH;
	}
	
	public function usePriorityMedium(){
		$this->priority = PRIORITY_MEDIUM;
	}
	
	public function usePriorityLow(){
		$this->priority = PRIORITY_LOW;
	}
}
?>
